package com.jmeter.functions;

import com.shenbianyun.bosskgpay.utils.PhoneNumber;
import org.apache.jmeter.engine.util.CompoundVariable;
import org.apache.jmeter.functions.AbstractFunction;
import org.apache.jmeter.functions.InvalidVariableException;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

/**
 * @author ：张一凡
 * @date ：2024年02月27日 16:55:57
 * @description：
 */
public class RandPhoneFunctions extends AbstractFunction {

    private static String key = "__RandomPhone";
    private static List<String> args = new LinkedList<>();


    @Override
    public String execute(SampleResult sampleResult, Sampler sampler) throws InvalidVariableException {
        String s = new PhoneNumber().getPhone();
        //System.out.println(s);
        return s;
    }

    @Override
    public void setParameters(Collection<CompoundVariable> collection) throws InvalidVariableException {
        //下面为固定写法
        Object[] values = collection.toArray();
    }

    @Override
    public String getReferenceKey() {
        return key;
    }

    @Override
    public List<String> getArgumentDesc() {
        return args;
    }
}
